home *** CD-ROM | disk | FTP | other *** search
/ Light ROM Gold / Light ROM Gold.iso / arexx / modeler / particle.rex < prev    next >
OS/2 REXX Batch file  |  1995-03-23  |  2KB  |  73 lines

  1. /* CMD: Points to Particles
  2.  *
  3.  * Converts all points into single-point polygons with the default surface.
  4.  * Creates new particles in an empty layer if there is one.  Currently uses
  5.  * all points in the layer, but could be restricted to selected points by
  6.  * setting selection mode to USER.
  7.  *
  8.  * 6/93  Stuart Ferguson
  9.  */
  10.     mxx="LWModelerARexx.port"
  11.     signal on error
  12.     signal on syntax
  13.     mxx_add = addlib(mxx,0)
  14.     call main
  15.     if (mxx_add) then call remlib(mxx)
  16.     exit
  17.  
  18.     syntax:
  19.     error:
  20.     t=Notify(1,'!Rexx Script Error','@'ErrorText(rc),'Line 'SIGL)
  21.     if (mxx_add) then call remlib(mxx)
  22.     exit
  23.  
  24.  
  25. main:
  26.  
  27. syscode = "Particles"
  28. tmpnam = "t:particles.tmp"
  29.  
  30. /* Use xfrm mode to scan through points, storing coordinates to tmp file.
  31.  */
  32. if (~open(plist, tmpnam, 'W')) then return
  33.  
  34. n = xfrm_begin()
  35. if (n = 0) then do
  36.     call close(plist)
  37.     return
  38. end
  39.  
  40. call meter_begin(n, syscode, "Reading Points")
  41. do i=1 to n
  42.     call writeln(plist, xfrm_getpos(i))
  43.     call meter_step()
  44. end i
  45. call meter_end()
  46. call xfrm_end()
  47.  
  48. call close(plist)
  49.  
  50.  
  51. /* Goto an empty layer.  If none, replace current data.
  52.  */
  53. emp = emptylayers()
  54. if (words(emp) = 0) then call delete()
  55. else call setlayer(word(emp,1))
  56.  
  57.  
  58. /* Read the point coordinates back in and create new data consisting
  59.  * of single-point polygons.
  60.  */
  61. if (~open(plist, tmpnam, 'R')) then return
  62.  
  63. call add_begin()
  64. call meter_begin(n, syscode, "Generating Particles")
  65. do i=1 to n
  66.     call add_polygon add_point(readln(plist))
  67.     call meter_step()
  68. end i
  69. call meter_end()
  70. call add_end()
  71.  
  72. return
  73.